/**
 * ajax请求时加载状态
 */
Look.prototype.loader = {
    show: function(){
        $(".loader").show();
        if ($(".flim").length == 0) {
            $("body").append('<div class="flim"></div>');
        }
    },
    hide: function(){
        $(".loader").hide();
        $(".flim").remove();
    }
}

/**
 * 提示信息
 */
Look.prototype.showInfo = {
    showTimer: $.timer(function(){
        look.showInfo.hide();
    }),
    add: function(){
        if ($(".info_panel").length == 0) {
            $("body").prepend('<div class="info_panel" id="infoPanel"><span></span></div>');
        }
    },
    hide: function(){
        this.showTimer.stop();
        this.add();
        $("#infoPanel").fadeOut();
    },
    right: function(text){
        this.add();
        this.showTimer.stop();
        this.showTimer.once(5000);
        $("#infoPanel").fadeIn().children("span").removeClass("errorInfo").html(text);
    },
    error: function(text){
        this.right(text);
        $("#infoPanel span").addClass("errorInfo");
    }
}

/**
 * 设置title
 * @param title
 * @return null
 */
Look.prototype.setTitle = function(title){
    document.title = title;
}

/**
 * 字符串查找
 * @param object 查找的字符
 * @param str 被查找的字符串
 * @return Boolean
 */
Look.prototype.hasString = function(object, str){
    var reg = eval("/" + object + "/gi");
    if (reg.test(str)) {
        return true;
    } else {
        return false;
    }
}

/**
 * 过滤掉数组中重复的项
 * @param arr 需要过滤的数组
 * @return newArray 过滤后的数组
 */
Look.prototype.uniqueArray = function(arr){
    var newArray = [];
    var m;
    while (arr.length > 0) {
        m = arr[0];
        newArray.push(m);
        arr = $.grep(arr, function(n, i){
            return n == m;
        }, true);
    }
    return newArray;
}

/**
 * 对象或者数组的深层拷贝
 * 拷贝前后的对象相互不影响
 * @param destination
 * @param source
 * @return
 */
Look.prototype.copyArray = function(destination, source){
    function getType(o){
        var _t;
        return ((_t = typeof(o)) == "object" ? o == null && "null" || Object.prototype.toString.call(o).slice(8, -1) : _t).toLowerCase();
    }
    for (var p in source) {
        if (getType(source[p]) == "array" || getType(source[p]) == "object") {
            destination[p] = getType(source[p]) == "array" ? [] : {};
            arguments.callee(destination[p], source[p]);
        } else {
            destination[p] = source[p];
        }
    }
}

/**
 * 返回字符串在规定字节长度内的值
 * @param val
 * @param max
 * @return String
 */
Look.prototype.getByteVal = function(val, max){
    var returnValue = '';
    var byteValLen = 0;
    var val = val.split("");
    for (var i = 0; i < val.length; i++) {
        if (val[i].match(/[^\x00-\xff]/ig) != null) {
            byteValLen += 2;
        } else {
            byteValLen += 1;
        }
        if (byteValLen > max) {
            break;
        }
        returnValue += val[i];
    }
    return returnValue;
}

/**
 * 返回字符串的字节长度
 * @param val
 * @return int
 */
Look.prototype.getByteLen = function(val){
    var len = 0, str = val.replace(" ", "$"), charCode = -1;
    for (var i = 0; i < str.length; i++) {
        charCode = str.charCodeAt(i);
        if (charCode >= 0 && charCode <= 128) {
            len += 1;
        } else {
            len += 2;
        }
    }
    return len;
}

/**
 * 全文查找去除空格
 * @param str
 * @return 已去除空格的字符
 */
Look.prototype.trimAll = function(str){
    return str.replace(/(^\s+)|(\s+$)|( )/g, "");
}

/**
 * 全文空格验证
 * @param str
 * @return
 */
Look.prototype.verifyTrim = function(str){
    var trimReg = /(^\s+)|(\s+$)|( )/g;
    return trimReg.test(str);
}

/**
 * 转换html标签
 * @param html
 * @return
 */
Look.prototype.encodeHtml = function(html){
    return html.replace(/</g, "&lt").replace(/>/g, "&gt");
}

/**
 * 生成id
 * @return
 */
Look.prototype.generateGuid = function(){
    var guid = "";
    for (var i = 1; i <= 32; i++) {
        var n = Math.floor(Math.random() * 16.0).toString(16);
        guid += n;
        //        if((i==8)||(i==12)||(i==16)||(i==20))
        //        	guid += "-";
    }
    return guid;
}

/**
 * 获取本地日期
 * @return 2012-06-02
 */
Look.prototype.getLocalDate = function(){
    var $date = new Date(), $y = $date.getFullYear(), $m = $date.getMonth() + 1, $d = $date.getDate();
    if ($m < 10) {
        $m = "0" + $m;
    }
    if ($d < 10) {
        $d = "0" + $d;
    }
    return $y + "-" + $m + "-" + $d;
}

/**
 * 获得上个月在昨天这一天的日期
 * @param {Object} date
 */
Look.prototype.getLastMonthDate = function(date){
    var daysInMonth = new Array([0], [31], [28], [31], [30], [31], [30], [31], [31], [30], [31], [30], [31]), dateArray = date.split("-"), strYear = parseFloat(dateArray[0]), strDay = parseFloat(dateArray[2]), strMonth = parseFloat(dateArray[1]);
    if (strYear % 4 == 0 && strYear % 100 != 0) {
        daysInMonth[2] = 29;
    }
    if (strMonth - 1 == 0) {
        strYear -= 1;
        strMonth = 12;
    } else {
        strMonth -= 1;
    }
    strDay = daysInMonth[strMonth] >= strDay ? strDay : daysInMonth[strMonth];
    if (strMonth < 10) {
        strMonth = "0" + strMonth;
    }
    if (strDay < 10) {
        strDay = "0" + strDay;
    }
    return strYear + "-" + strMonth + "-" + strDay;
}

/**
 * 指定日期增加天数
 * @param {Object} date
 * @param {Object} num
 */
Look.prototype.addDaysByDate = function(date, num){
    return new Date(Date.parse(date) + (86400000 * num));
}

/**
 * 指定日期减去天数
 * @param {Object} date
 * @param {Object} num
 */
Look.prototype.reduceDaysByDate = function(date, num){
    return new Date(Date.parse(date) - (86400000 * num));
}

/**
 * 日期格式化
 * "yyyy-MM-dd"
 * @param {Object} date
 * @param {Object} format
 */
Look.prototype.dateFormat = function(date, format){
    var o = {
        "M+": date.getMonth() + 1, //month
        "d+": date.getDate(), //day
        "h+": date.getHours(), //hour
        "m+": date.getMinutes(), //minute
        "s+": date.getSeconds(), //second
        "q+": Math.floor((date.getMonth() + 3) / 3), //quarter
        "S": date.getMilliseconds() //millisecond
    }
    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
}

/**
 * 获取两个日期的间隔时间的天数（f是当前日期，s是之后的）
 * @param f 如：2012-06-02
 * @param s 如：2013-06-02
 * @return int
 */
Look.prototype.getDiffDays = function(f, s){
    var dateArray;
    var monthDays = [0, 3, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1];
    dateArray = f.split("-");
    var date1Year = dateArray[0];
    var date1Month = dateArray[1];
    var date1Day = dateArray[2];
    dateArray = s.split("-");
    var date2Year = dateArray[0];
    var date2Month = parseInt((dateArray[1]).replace(/\b(0+)/gi, ""));
    var date2Day = parseInt((dateArray[2]).replace(/\b(0+)/gi, ""));
    //判断年份是否是闰年 
    function isLeapYear(year){
        if (year % 4 == 0 && (year % 100 != 0) || (year % 400 == 0)) {
            return true;
        }
        return false;
    }
    
    //判断前后两个日期  
    function validatePeriod(fyear, fmonth, fday, byear, bmonth, bday){
        if (fyear < byear) {
            return true;
        } else if (fyear == byear) {
            if (fmonth < bmonth) {
                return true;
            } else if (fmonth == bmonth) {
                if (fday <= bday) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    if (validatePeriod(date1Year, date1Month, date1Day, date2Year, date2Month, date2Day)) {
        var firstDate = new Date(date1Year, date1Month, date1Day);
        var secondDate = new Date(date2Year, date2Month, date2Day);
        var result = Math.floor((secondDate.getTime() - firstDate.getTime()) / (1000 * 3600 * 24));
        for (j = date1Year; j < date2Year; j++) {
            if (isLeapYear(j)) {
                monthDays[1] = 2;
            } else {
                monthDays[1] = 3;
            }
            for (i = date1Month - 1; i < date2Month; i++) {
                result = result - monthDays[i];
            }
        }
        return result;
    } else {
        return;
    }
}

/**
 * 获取指定的URL参数值
 * @param {String} paramName URL参数
 * @param {String} from 来源
 * @return paramValue URL参数值
 */
Look.prototype.getParam = function(paramName){
    var paramValue = "";
    var isFound = false;
    if (location.search.indexOf("?") == 0 && location.search.indexOf("=") > 1) {
        var arrSource = unescape(location.search).substring(1, location.search.length).split("&");
        i = 0;
        while (i < arrSource.length && !isFound) {
            if (arrSource[i].indexOf("=") > 0) {
                if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) {
                    paramValue = arrSource[i].split("=")[1];
                    isFound = true;
                }
            }
            i++;
        }
    }
    return paramValue;
}

/**
 * 获取指定的URL中的hash参数值
 * @param {String} paramName URL参数
 * @return paramValue URL参数值
 */
Look.prototype.getHashParam = function(paramName){
    var paramValue = "";
    var isFound = false;
    if (location.hash.indexOf("#") == 0 && location.hash.indexOf("=") > 1) {
        var arrSource = unescape(location.hash).substring(1, location.hash.length).split("&");
        i = 0;
        while (i < arrSource.length && !isFound) {
            if (arrSource[i].indexOf("=") > 0) {
                if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) {
                    paramValue = arrSource[i].split("=")[1];
                    isFound = true;
                }
            }
            i++;
        }
    }
    return paramValue;
}

/**
 * 获取指定的cookie中的参数值
 * @param key
 * @param source
 * @return
 */
Look.prototype.getCookieParam = function(key, source){
    if ($.cookie(source)) {
        var arr = $.cookie(source).split("&");
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].split("=")[0] == key) {
                return arr[i].split("=")[1];
            }
        }
    }
}

/**
 * 获取String中的参数值
 * @param key
 * @param source
 * @return
 */
Look.prototype.getStringParam = function(key, source){
    if (source.indexOf("#") != -1 || source.indexOf("?") != -1) {
        source = source.substr(1);
    }
    var arr = source.split("&");
    for (var i = 0; i < arr.length; i++) {
        if (arr[i].split("=")[0] == key) {
            return arr[i].split("=")[1];
        }
    }
}

/**
 * 添加参数值
 * @param key
 * @param source
 * @return
 */
Look.prototype.addParam = function(key, source){
    var theNewStr = source;
    for (var j = 0; j < key.length; j++) {
        theNewStr += "&" + key[j][0] + "=" + key[j][1];
    }
    return theNewStr;
}

/**
 * 重新设置参数值
 * @param {Array} key 如：[["aa","11"],["bb","22"]]
 * @param {String} source
 * @return
 */
Look.prototype.setParam = function(key, source){
    var reg = /^[#]|[?]/, type = reg.exec(source), theNewStr = source.replace(eval("/(^[" + type + "])/"), "").replace(/&hash_random=[a-zA-Z0-9]+/g, "");
    function single(keyStr, sourceStr){
        var arr = sourceStr.split("&"), newArr = "";
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].split("=")[0] == keyStr[0]) {
                newArr += keyStr[0] + "=" + keyStr[1] + "&";
            } else {
                newArr += arr[i].split("=")[0] + "=" + arr[i].split("=")[1] + "&";
            }
        }
        return newArr.replace(/[&]$/, "");
    }
    for (var j = 0; j < key.length; j++) {
        theNewStr = single(key[j], theNewStr);
    }
    return type + theNewStr.replace(/[&]$/, "") + "&hash_random=" + look.generateGuid();
}

/**
 * 选择内容方法
 * @param {Object} obj 被选择的文本对象
 */
Look.prototype.selectContents = function(obj){
    $(obj).each(function(i){
        var node = this;
        var selection, range, doc, win;
        if ((doc = node.ownerDocument) &&
        (win = doc.defaultView) &&
        typeof win.getSelection != 'undefined' &&
        typeof doc.createRange != 'undefined' &&
        (selection = window.getSelection()) &&
        typeof selection.removeAllRanges != 'undefined') {
            range = doc.createRange();
            range.selectNode(node);
            if (i == 0) {
                selection.removeAllRanges();
            }
            selection.addRange(range);
        } else if (document.body &&
        typeof document.body.createTextRange != 'undefined' &&
        (range = document.body.createTextRange())) {
            range.moveToElementText(node);
            range.select();
        }
    });
}

/**
 * 串联加载指定的脚本
 * 串联加载[异步]逐个加载，每个加载完成后加载下一个
 * 全部加载完成后执行回调
 * @param {Array|String} scripts 指定的脚本们
 * @param {Function} callback 成功后回调的函数
 */
Look.prototype.seriesLoadScripts = function(scripts, callback){
    if (typeof(scripts) != "object") 
        var scripts = [scripts];
    var HEAD = document.getElementsByTagName("head").item(0) || document.documentElement;
    var s = new Array(), last = scripts.length - 1, recursiveLoad = function(i){ //递归
        s[i] = document.createElement("script");
        s[i].setAttribute("type", "text/javascript");
        s[i].onload = s[i].onreadystatechange = function(){ //Attach handlers for all browsers
            if (!0 || this.readyState == "loaded" || this.readyState == "complete") {
                this.onload = this.onreadystatechange = null;
                this.parentNode.removeChild(this);
                if (i != last) 
                    recursiveLoad(i + 1);
                else if (typeof(callback) == "function") 
                    callback();
            }
        }
        s[i].setAttribute("src", scripts[i]);
        HEAD.appendChild(s[i]);
    };
    recursiveLoad(0);
}

/**
 * 创建空白iframe，用于请求某个URL的页面
 * @param {Object} url
 * @param {Object} id
 * @param {Object} callback
 */
Look.prototype.createBlankIframe = function(url, id, callback){
	var iframe = document.createElement("iframe");
	iframe.src = url;
	iframe.id = id;
	iframe.width = 0;
	iframe.height = 0;
	iframe.marginHeight = 0;
	iframe.marginWidth = 0;
	var fn = function(){
		callback();
		document.getElementById(id).remove();
	}
	
	if (iframe.attachEvent) {
		iframe.attachEvent("onload", function(){
			fn();
		});
	} else {
		iframe.onload = function(){
			fn();
		};
	}
	document.body.appendChild(iframe);
}

/**
 * JSON字符串格式化
 * @param {Stringh} txt
 * @param {Boolean} compress 是否为压缩模式 true:压缩,false:不压缩
 */
Look.prototype.JSONFormat = function(txt, compress){
    var indentChar = '    ';
    if (/^\s*$/.test(txt)) {
        return;
    }
    try {
        var data = eval('(' + txt + ')');
    } catch (e) {
        return;
    };
    var draw = [], last = false, This = this, line = compress ? '' : '\n', nodeCount = 0, maxDepth = 0;
    
    var notify = function(name, value, isLast, indent/*缩进*/, formObj){
        nodeCount++;/*节点计数*/
        for (var i = 0, tab = ''; i < indent; i++) 
            tab += indentChar;/* 缩进HTML */
        tab = compress ? '' : tab;/*压缩模式忽略缩进*/
        maxDepth = ++indent;/*缩进递增并记录*/
        if (value && value.constructor == Array) {/*处理数组*/
            draw.push(tab + (formObj ? ('"' + name + '":') : '') + '[' + line);/*缩进'[' 然后换行*/
            for (var i = 0; i < value.length; i++) 
                notify(i, value[i], i == value.length - 1, indent, false);
            draw.push(tab + ']' + (isLast ? line : (',' + line)));/*缩进']'换行,若非尾元素则添加逗号*/
        } else if (value && typeof value == 'object') {/*处理对象*/
            draw.push(tab + (formObj ? ('"' + name + '":') : '') + '{' + line);/*缩进'{' 然后换行*/
            var len = 0, i = 0;
            for (var key in value) 
                len++;
            for (var key in value) 
                notify(key, value[key], ++i == len, indent, true);
            draw.push(tab + '}' + (isLast ? line : (',' + line)));/*缩进'}'换行,若非尾元素则添加逗号*/
        } else {
            if (typeof value == 'string') 
                value = '"' + value + '"';
            draw.push(tab + (formObj ? ('"' + name + '":') : '') + value + (isLast ? '' : ',') + line);
        };
            };
    var isLast = true, indent = 0;
    notify('', data, isLast, indent, false);
    return draw.join('');
};

/**
 * 数据请求方法
 * @param requestData
 * @param httpHeader
 * @param responseFn
 * @return
 */
function dataConn(url, requestData, responseFn, completeFn, async){
    $.ajax({
        type: "POST",
        url: url,
        dataType: "text",
        data: requestData,
        timeout: 15000,
        async: (async != undefined ? async : true),
        beforeSend: function(XMLHttpRequest){
        },
        success: function(data, textStatus, XMLHttpRequest){
            var back = eval('(' + data + ')');
            if (back.code == "302") {
                look.showInfo.error(back.code + look._I18N_DATA.$413/**：非法登录，正在为您跳转……**/);
                location.href = back.message;
                return false;
            }
            if (back != null) {
                if (back.code == 9001 || back.code == 403) {
                    look.showInfo.error(back.code + " : " + back.message + " [" + url + "]");
                    return false;
                }
                if (responseFn != undefined) {
                    try {
                        eval(responseFn(back, textStatus));
                    } catch (e) {
                        look.showInfo.error("[ERROR] name : " + e.name + ", message: " + e.message);
                    }
                }
            } else {
                look.showInfo.error(look._I18N_DATA.$414/**网络连接出错！**/);
            }
        },
        error: function(XMLHttpRequest, error){
            if (error == "timeout") {
                look.showInfo.error(look._I18N_DATA.$415/**请求超时：请求系统返回数据超时！请稍候再试吧…**/);
            } else {
                look.showInfo.error(error + look._I18N_DATA.$416/**：返回数据可能为非JSON格式…**/);
            }
        },
        complete: function(XMLHttpRequest, textStatus){
            if (completeFn != undefined && completeFn != null) {
                try {
                    eval(completeFn(textStatus));
                } catch (e) {
                    look.showInfo.error("[ERROR] name : " + e.name + ", message: " + e.message);
                }
            }
        }
    });
}

/**
 * 同步加载页面
 * @param {String} container 页面存放的div容器
 * @param {String} url 加载的页面URL
 * @param {String} callback 回调函数
 */
function loadPage(container, url, callback){
    $.ajax({
        url: url,
        async: false,
        success: function(back){
            if (jQuery.isPlainObject(back)) {
                look.showInfo.error(back.code + " : " + back.message + " [" + url + "] ");
                if (back.code == "302") {
                    location.href = back.message;
                }
                return false;
            }
            $(container).html(back);
        },
        complete: function(){
            if (callback != undefined) {
                eval(callback);
            }
        },
        error: function(XmlHttpRequest, textStatus, errorThrown){
            $.lookPop({
                type: -1,
                title: "Fail to Load Page",
                closeSubset: true,
                html: 
					'<div style="width:500px;">' +
                	'	<div class="pop_content_word">' +
                	'		<span class="pop_content_span pop_warning_icon">' + look._I18N_DATA.$802/**加载页面出错，请进行{refresh}，然后再试一次。**/.replace(/{refresh}/ig, '<a href="javascript:window.location.reload();" class="blue">' + look._I18N_DATA.$611/**刷新**/ + '</a>') + '</span>' +
                	'	</div>' +
                	'</div>'
            });
        }
    });
}

/**
 * 分页
 * @param id 插入页码的地方
 * @param pageSize 每页数目
 * @param hashArray hash数组值
 * @param count 总数
 * @return
 */
function setPager(id, pageSize, hashArray, count){
    var theHtml = "", className = "";
    if (count == 0 || count == undefined) {
        $(id).html(theHtml);
        return false;
    }
    var currentPager = 1, pageStep = 5, pageCount, beginPage, endPage;
    //分页算法
    pageCount = Math.ceil(count / pageSize);
    currentPager = parseInt(hashArray[1] ? hashArray[1] : 1);
    if (pageCount < currentPager) {
        currentPager = pageCount;
    }
    if (currentPager < 1) {
        currentPager = 1;
    }
    beginPage = (currentPager - Math.ceil(pageStep / 2));
    if (beginPage < 1) {
        beginPage = 1;
    }
    endPage = currentPager + pageStep / 2;
    if (endPage > pageCount) {
        endPage = pageCount + 1;
    }
    
    if (currentPager == 1) {
        theHtml += '<a href="javascript:" class="disabled" look-lang="$40">首页</a>';
        theHtml += '<a href="javascript:" class="disabled" look-lang="$41">上一页</a>';
    } else {
        theHtml += '<a href="' + hashArray[0] + '" look-lang="$40">首页</a>';
        if (currentPager == 2) {
            theHtml += '<a href="' + hashArray[0] + '" look-lang="$41">上一页</a>';
        } else {
            theHtml += '<a href="' + hashArray[0] + "&page=" + (currentPager - 1) + '" look-lang="$41">上一页</a>';
        }
    }
    for (var i = beginPage; i < endPage; i++) {
        if (currentPager == i) {
            className = "selected";
        } else {
            className = "";
        }
        if (i == 1) {
            theHtml += '<a href="' + hashArray[0] + '" class="' + className + '">' + (i) + '</a>';
        } else {
            theHtml += '<a href="' + hashArray[0] + "&page=" + i + '" class="' + className + '">' + (i) + '</a>';
        }
    }
    if (currentPager == pageCount) {
        theHtml += '<a href="javascript:" class="disabled" look-lang="$42">下一页</a>';
        theHtml += '<a href="javascript:" class="disabled" look-lang="$43">末页</a>';
    } else {
        theHtml += '<a href="' + hashArray[0] + "&page=" + (currentPager + 1) + '" look-lang="$42">下一页</a>';
        theHtml += '<a href="' + hashArray[0] + "&page=" + pageCount + '" look-lang="$43">末页</a>';
    }
    theHtml += '<span class="pager_total"><i look-lang="$44">共</i><span id="pagerTotal">' + pageCount + '</span><i look-lang="$45">页</i></span><span class="goto_pager" look-lang="$46">到</span><input type="text" class="text" id="gotoPage" /><span class="goto_pager" look-lang="$45">页</span><a href="javascript:" id="gotoSubset" class="a_as_button" look-lang="$600">确定</a>';
    $(id).html(theHtml);
    $("#gotoPage").bind("blur", function(){
        var i = $(this).val();
        if (isNaN(i) || i <= 0) {
            i = 1;
        }
        if (i > pageCount) {
            i = pageCount;
        }
        if (i != "") {
            if (i == 1) {
                $("#gotoSubset").attr("href", hashArray[0]);
            } else {
                $("#gotoSubset").attr("href", hashArray[0] + "&page=" + i);
            }
        }
    });
}

function setJsPager(id, currentPager, pageSize, count, callback){
    var theHtml = "", className = "";
    $(id).html(theHtml);
    var pageStep = 5, pageCount, beginPage, endPage;
    //分页算法
    pageCount = Math.ceil(count / pageSize);
    if (pageCount < currentPager) {
        currentPager = pageCount;
    }
    if (currentPager < 1) {
        currentPager = 1;
    }
    beginPage = (currentPager - Math.ceil(pageStep / 2));
    if (beginPage < 1) {
        beginPage = 1;
    }
    endPage = currentPager + pageStep / 2;
    if (endPage > pageCount) {
        endPage = pageCount + 1;
    }
    
    if (currentPager == 1) {
        theHtml += '<a href="javascript:" class="disabled" look-lang="$40">首页</a>';
        theHtml += '<a href="javascript:" class="disabled" look-lang="$41">上一页</a>';
    } else {
        theHtml += '<a href="javascript:" num="0" look-lang="$40">首页</a>';
        if (currentPager == 2) {
            theHtml += '<a href="javascript:" num="0" look-lang="$41">上一页</a>';
        } else {
            theHtml += '<a href="javascript:" num="' + (currentPager - 1) + '" look-lang="$41">上一页</a>';
        }
    }
    for (var i = beginPage; i < endPage; i++) {
        if (currentPager == i) {
            className = "selected";
        } else {
            className = "";
        }
        if (i == 1) {
            theHtml += '<a href="javascript:" class="' + className + '" num="0">' + (i) + '</a>';
        } else {
            theHtml += '<a href="javascript:" class="' + className + '" num="' + i + '">' + (i) + '</a>';
        }
    }
    if (currentPager == pageCount) {
        theHtml += '<a href="javascript:" class="disabled" look-lang="$42">下一页</a>';
        theHtml += '<a href="javascript:" class="disabled" look-lang="$43">末页</a>';
    } else {
        theHtml += '<a href="javascript:" num="' + (currentPager + 1) + '" look-lang="$42">下一页</a>';
        theHtml += '<a href="javascript:" num="' + pageCount + '" look-lang="$43">末页</a>';
    }
    theHtml += '<span class="pager_total"><i look-lang="$44">共</i><span id="pagerTotal">' + pageCount + '</span><i look-lang="$45">页</i></span>';
    $(id).html(theHtml);
    $(id).children("a").unbind("click").bind("click", function(){
        if ($(this).hasClass("disabled")) {
            return false;
        }
        eval(callback($(this).attr("num")));
    });
}
